package com.jic.market.request.rest.discount;

import com.jic.market.response.rest.coupon.QueryCouponPersonResponse;
import com.jic.market.response.rest.discount.GiftDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author yinhaijun
 * @date: 2020/4/16
 */
@Data
public class DiscountQueryRequest extends DiscountBaseRequest implements Serializable {

    private static final long serialVersionUID = -8969884589726229212L;

    @Valid
    @NotEmpty(message = "商品集合不能为空")
    @ApiModelProperty(notes = "商品集合", required = true)
    private List<PromotionGoods> promotionGoodsList;

    @Valid
    @ApiModelProperty(notes = "优惠劵集合", required = false)
    private List<QueryCouponPersonResponse> couponCodeInfoList;

    // 购物车查询时返回，然后在结算页传入
    @ApiModelProperty(notes = "赠品或换品")
    private Map<String, List<GiftDetail>> giftMap;

    public void check(){
        if(null != promotionGoodsList && !promotionGoodsList.isEmpty()){
            promotionGoodsList.forEach(promotionGoods -> {
                promotionGoods.check();
            });
        }
    }
}
